package restaurant;

import restaurant.iterators.Iterator;

/**
 * The Class cmdMenuByCourse.
 * 
 * @author Ebonie
 */

public class cmdMenuByCourse implements Command
{

	/** The info. */
	private InformationAggregator info;

	/** The course. */
	private String course;



	/**
	 * Instantiates a new cmd menu by course.
	 * 
	 * @param info the info
	 * @param course the course
	 */
	public cmdMenuByCourse(InformationAggregator info, String course) {
		this.info = info;
		this.course = course;
	}



	/**
	 * Execute.
	 * 
	 * @return the menu by course.
	 * @see restaurant.Command#execute()
	 */
	@Override
	public Object execute()
	{
		Menu menu = info.getMenu();
		Iterator courseIterator = menu.getByCourseIterator(course);
		MenuItem item;
		Menu courseMenu = new Menu();

		while (courseIterator.hasNext()) {
			item = (MenuItem) courseIterator.next();

			if (item.isAvailable())
				courseMenu.add(item);
		}

		return courseMenu;
	}

}
